﻿<%@ Page Title="添加正则表达式" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Add.aspx.cs" Inherits="RegexLib.Web.Views.Regex.Add" %>
<asp:Content ID="Content1" ContentPlaceHolderID="headContentPlaceHolder" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div class="box">
	<div class="bt">添加正则表达式</div>
	<div class="bc">
	<form id="TheForm">
		<fieldset>
			<legend>标题</legend>
			<p class="ds">请输入正则表达式的标题（100字之内）。</p>
			<input type="text" name="title" maxlength="100" size="200" style="width:520px" class="input" />
		</fieldset>
		<fieldset>
			<legend>说明</legend>
			<p class="ds">请对正则表达式进行简短说明（1000字之内）。</p>
			<textarea name="description" class="input-ta" cols="200"></textarea>
		</fieldset>
		<fieldset>
			<legend>模式</legend>
			<p class="ds">请输入正则表达式模式串。</p>
			<textarea name="pattern" class="input-ta" cols="200"></textarea>
		</fieldset>
		<fieldset>
			<legend>访问路径</legend>
			<p class="ds">请输入该正则表达式的访问路径。可以通过
			<strong>http://regex-lib.net/ViewRegex/<span id="">[访问路径]</span>/</strong>
			来查看该正则表达式。</p>
			<p class="ds">如果不填写，则系统自动生成一个随机的访问路径。访问路径一旦设定，则不能再更改。</p>
			<p class="ds">请使用50个以内的小写字母和数字以及连字符（-），连字符不能位于开始和结束，也不能连续使用两个连字符。</p>
			<input type="text" name="accessKey" maxlength="100" size="200" style="width:520px" class="input" />
		</fieldset>
		<fieldset>
			<legend>关键字</legend>
			<p class="ds">多个关键字之间请用全角或半角的<strong>逗号</strong>（“,”、“，”）或<strong>分号</strong>（“;”、“；”）分隔。空格<strong>不能</strong>分隔关键字。单个关键字的长度请限制在50字之内。</p>
			<input type="text" name="keywords" size="200" style="width:520px" class="input" />
		</fieldset>
	</form>
	<div><button id="SubmitBtn">添加到正则表达式库</button></div>
	<p><span id="MsgSpan"></span></p>
	</div>
</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
<script type="text/javascript">
var c_TheForm;
var c_SubmitBtn;
var c_MsgSpan;

function GetElements()
{
	c_TheForm = YAHOO.util.Dom.get("TheForm");
	c_SubmitBtn = YAHOO.util.Dom.get("SubmitBtn");
	c_MsgSpan = YAHOO.util.Dom.get("MsgSpan");
}

function DoSubmit()
{
	c_SubmitBtn.disabled = true;

	var callback =
	{
		success: function(o)
		{
			var data = YAHOO.lang.JSON.parse(o.responseText);
			if(data.IsError)
			{
				c_MsgSpan.className = "err";
				c_MsgSpan.innerText = data.Message;
				
				c_SubmitBtn.disabled = false;
			}
			else
			{
				window.location = data.Message;
			}
		},
		failure: function(o)
		{
			c_MsgSpan.className = "err";
			c_MsgSpan.innerText = "连接错误。";
			c_SubmitBtn.disabled = false;
		},
		timeout:30000
	};
	YAHOO.util.Connect.setForm(c_TheForm);
	YAHOO.util.Connect.asyncRequest("POST", "/Regex/AddSubmit/", callback, null);
}

function init()
{
	GetElements();
	YAHOO.util.Event.addListener(c_SubmitBtn, "click", DoSubmit);
}

YAHOO.util.Event.onDOMReady(init);
</script>
</asp:Content>
